package com.trs.publish.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trs.publish.domain.Role;
import com.trs.publish.repository.RoleRepository;



/**
 * @author jia.haihong
 */
@Service
public class RoleService{

	@Autowired
    private RoleRepository roleRepository;

	public List<Role> getAllRoles() {
		return roleRepository.findRoles();
	}

	public List<Role> getList(Role role) {
		return roleRepository.findByRole(role);
	}
	
	@Transactional
	public void deleteRole(long id) {
		roleRepository.delete(id);
	}

	public Role findById(long id) {
		return roleRepository.find(id);
	}
	
	@Transactional
	public void save(Role role) {
		 roleRepository.save(role);
	}
	
	@Transactional
	public void update(Role role) {
		roleRepository.update(role);
	}

	public Role findByName(String rolename) {
		return roleRepository.findByName(rolename);
	}

}
